/**
 * Created by yvdedu.com on 2016/10/20.
 */

var LoginUser=0;





!function () {
    $.post("/getMineInfo",function (o) {

        //logo 3D  模块---------------------------------------------------------------


//logo 文字模块- - - -- - - -  - - ----------------------------------------------------------------------
        !function () {
            if (o){
                LoginUser=JSON.parse(o);
            }else{
                $(function(){
                    $(".content.hot").click();
                })
            }
            var pTarget=$(".LogoP");
            var csDiv=$(".logo div");
            var cs=$(".logo canvas");
            var texts=["社区","编写文章","我的主页","好友聊天","消息提示",""];
            if(o){
                csDiv.mousedown(backGroundGreen);
                csDiv[0].onclick=function(){
                    location.href="/";
                };
                csDiv[1].onclick=function(){
                    $("#openEdit").click();
                };
                csDiv[2].onclick=function(){
                    location.href="user";
                };
                csDiv[3].onclick=function(){
                    $("#myFriends").click();
                };
                for (var i=0;i<csDiv.length;++i){
                    var aa=cb(cs[i],texts[i],true);
                    var bb=cb(cs[i],texts[i]);
                    $(cs[i]).mouseover(aa);
                    $(cs[i]).mouseleave(bb);
                }
                drawWhat();
            }else{
                drawLogo();
                csDiv.click(function () {
                   $(".loginButton").click();
                });
                csDiv.mousedown(backGroundRed);
            }
            csDiv.mouseup(backGroundNormal);

            function backGroundGreen() {
                this.style.background="radial-gradient( green, white)";
            }
            function backGroundRed() {
                this.style.background="radial-gradient(red,white)";
            }
            function backGroundNormal() {
                csDiv.css("background","rgba(230,230,230,0.8)");
            }

            function drawLogo() {
                for (var i=0;i<texts.length;++i){
                    draw(cs[i],"社区",true);
                }
            }

            function drawAll(k){
                for (var i=0;i<texts.length;++i){
                    if(k==i){
                        draw(cs[i],texts[i],true);
                        csDiv[i].style.zIndex=9;
                    }else{
                        draw(cs[i],texts[i]);
                        csDiv[i].style.zIndex=1;
                    }
                }
            }
            function cb(c,text,selected){
                return function (){
                    draw(c,text,selected);
                };
            }
            function drawWhat() {
                if(!o)return;
                var href=location.href;
                var arr=href.split("/");
                var result=arr[arr.length-1];
                var regexp=new RegExp("^user[^\\d]?||^user"+LoginUser.id+"[^\\d]?");
                if(result.match(regexp)[0]!=""){
                    drawAll(2);
                }else {
                    drawAll(0);
                }
            }

            function draw(c,text,selected) {
                c.width=100;
                c.height=100;
                var length=text.length;
                var fontSize= (c.width-10)/length;
                var ctx=c.getContext("2d");
                ctx.font=fontSize+"px 微软雅黑";
                ctx.textAlign="center";
                ctx.textBaseline="middle";
                if(length<4){
                    ctx.lineWidth=2;
                }else {
                    ctx.lineWidth=1;
                }
                if(selected){
                    var gradien=ctx.createLinearGradient(0,0,c.width,0);
                    gradien.addColorStop("0",randomColor());
                    gradien.addColorStop("0.5",randomColor());
                    gradien.addColorStop("1",randomColor());
                    ctx.strokeStyle=gradien;
                }else{
                    ctx.strokeStyle="#999";
                }
                ctx.strokeText(text,50,50)
            }
            var tot;
            var pi=0;
            var v=0;
            var init=false;
            function showMenu(){
                init=true;
                pTarget.css("opacity","1");
                cl();
            }
            function cl(){
                if(init){
                    var ro=Math.PI*2/(cs.length);
                    var r=100;
                    for (var i=0;i<cs.length;++i){
                        $(csDiv[i]).removeClass("logo"+(i+1));
                        var left=r*Math.cos(i*ro+pi);
                        var top=r*Math.sin(i*ro+pi);
                        $(csDiv[i]).css("border-radius", "50%");
                        $(csDiv[i]).css({left:50+left+"px",top:50+top+"px"})
                    }
                    pi+=v;
                    tot=setTimeout(cl,100);
                }
            }

            function hideMenu(){
                init=false;
                setTimeout(function(){
                    if(!init){
                        clearTimeout(tot);
                        drawWhat();
                        pTarget.css("opacity","0.5");
                        for (var i=0;i<cs.length;++i){
                            $(csDiv[i]).css("border-radius", "10px");
                            $(csDiv[i]).addClass("logo"+(i+1));
                            csDiv.css({left:"50px",top:"50px"})
                        }
                    }
                },100);
            }

            function getRo(e){
                var X=pTarget[0].offsetLeft;
                var Y=pTarget[0].offsetTop;
                var x= e.clientX;
                var y= e.clientY;
                var dx=x-X-50;
                var dy=y-Y-50;
                var length=Math.sqrt(dx*dx+dy*dy);
                if(length<50){
                    v=0.1
                }else {
                    v=0.01
                }
            }

            pTarget.hover(showMenu,hideMenu);
            pTarget.mousemove(getRo);
            pTarget.mouseleave(hideMenu)


        }();


    })
}();

$(function(){
    function doNoting(e){
        e.preventDefault();
    }
    $(".search .btn").click(function(){
        var text=$(".search .ipt").val();
        var range=location.href;
        var mch=range.match(/\/[^\\d]*/);
        var search="";
        if(mch[1]=="/infocenter"){
            search="?search="+text+"&range=infocenter";
        }else if(mch[1]=="/user"){
            var targetId=range.match(/user\\d*/)?url.match(/user\\d*/).substr(4):0;
            search="?search="+text+"&range=user&id="+targetId;
        }else{
            search="?search="+text+"&range=main";
        }
        open("/search"+search);
    })
});



//显示、隐藏滚动条--------------------------------------------------------------
!function(){
    var cont=$(".ArticlePanel,.Article");
    // for(var i=0;i<cont.length;i+=2){
    //     contentFloat(cont[i],"left");
    //     if (i+1>=cont.length) break;
    //     contentFloat(cont[i+1],"right");
    // }

    function hideScrollbar(){
        cont.css("overflow-y","hidden");
    }
    cont.click(showScrollbar);
    function showScrollbar() {
        hideScrollbar();
        $(this).css("overflow-y","auto");
    }
    //$(document).not(".ArticlePanel").not(".Article").click(hideScrollbar);
    $("#bg").click(hideScrollbar);
    $("#bg").click(hideScrollbar);
}();



//随机颜色方法------------------------------------------------------------------
function randomColor() {
    return "rgba("+Math.floor(Math.random()*155)+","+Math.floor(Math.random()*155)+","+Math.floor(Math.random()*155)+",1)";
}





// 背景模块------------------------------------------------------------------
! function () {
    var c=document.getElementById("bg");
    var ctx=c.getContext("2d");
    var cWidth=innerWidth;
    var cHeight=innerHeight;
    c.height=cHeight;
    c.width=cWidth;
    var bgclr="rgba(0,0,0,0)";
    var run=function(num){
        for (var i=0;i<num;++i){
            draw();
        }
    };

    var draw=function(){
        var color=randomColor();
        generate(color);
    };

    var generate=function(color){
        var r=Math.floor(Math.random()*20+20);
        var r1=Math.floor(Math.random()*2*r+r+1);
        var x=Math.floor(Math.random()*(cWidth-2*r)+r);
        var y=Math.floor(Math.random()*(cHeight-2*r)+r);
        var dr=Math.random()*(r1-r-2)+1;
        var rad=Math.random()*Math.PI*2;
        var x1=x+Math.floor(dr*Math.cos(rad));
        var y1=y+Math.floor(dr*Math.sin(rad));
        ctx.beginPath();
        var grt=ctx.createRadialGradient(x,y,r,x1,y1,r1);
        grt.addColorStop(0,color);
        grt.addColorStop(1,bgclr);
        ctx.fillStyle=grt;
        ctx.arc(x1,y1,r1,0,2*Math.PI);
        ctx.fill();
    };
    run(10);
}();




//拖动效果模块-----------------------------------------------------------------
!function(){

    var target;
    var move=false;
    var overinput=false;
    var x, y,mX,mY;
    function Move(x,y){
        target.css({left:x,top:y})
    }

    function getFix(e) {
        if (overinput){
            move=false;
            return;
        }
        x=this.parentNode.offsetLeft;
        y=this.parentNode.offsetTop;
        mX=e.clientX;
        mY= e.clientY;
        move=true;
        target=$(this.parentNode);
        Move(x,y);
    }

    function transformTarget(e) {
        if(!move)return;
        e.preventDefault();
        target.addClass("pa onTop");
        var tempx=e.clientX;
        var tempy= e.clientY;
        Move(tempx-mX+x,tempy-mY+y);
    }


    $(".move").mousedown(getFix);
    $(window).mousemove(transformTarget);
    $(window).mouseup(stop);
    //$("#editor").mousedown(stop);
    //$("#editor").mouseup(stop);
    //$("input,textarea").mousedown(stop);
    //$("input,textarea,iframe").mouseover(function () {
    //    overinput=true;
    //})
    //$("input,textarea").mouseleave(function () {
    //    overinput=false;
    //})
    function stop() {
        if(move){
            target.removeClass("pa onTop");
            move=false;
        }
    }


}();


//编辑文章模块----------------------------------------------------------------
!function () {
    var openEditTarget=$("#openEdit");
    var EditButtonTarger=$(".EditButton");
    var deleteArticleTarget=$(".deleteArticle.linkCss");
    var id=0;
    var Ptarget=$(".EditArticle");
    var ue = UE.getEditor('editor');
   
    function uploadArticle() {
        var content=ue.getContent();
        var title=content.match(/<([a-z]+?[0-9]*?)( [^>]*?|)>([^<]+?)<\/\1>/)[0].replace(/<([a-z]+?[0-9]*?)( [^>]*?|)>([^<]+?)<\/\1>/,"$3");
        var role=$(".ArticleSelect").val();
        var top=$(".TopCheckBox").is(":checked");
        $.post("/saveArticle",{name:title,content:content,role:role,top:top,id:id},function (o) {
            if (o){
                location.href="/Article"+o;
            }
        })
    }
    function openEdit(){
        ue.setHeight(420);
        Ptarget.css({left:"20%",top:"20%"});
        setContent("");
        EditButtonTarger.text("确认提交");
        Ptarget.fadeIn();
    }

    function delArticle(){
        $.post("/delArticle",{id:id},function(o){
            if(o==true){
                location.href="/user";
            }else {
            }
        })
    }

    function setContent(content){
        ue.setContent(content,false);
    }

    function insertHtml(html){
        ue.execCommand('insertHtml', html)
    }


    deleteArticleTarget.click(function(){
        id=this.id.substring(1);
        delArticle();
    });
    $(".eArticle.linkCss").click(function(){
        ue.setHeight(420);
        id=this.id.substring(1);
        $.post("/getArticleContent",{id:id},function(o){
            var js=JSON.parse(o);
            openEdit();
            setContent(js.content);
            $(".ArticleSelect").val(js.role);
            if(js.topTime)
            $(".TopCheckBox").attr("checked","checked");
            EditButtonTarger.text("确认修改");
        })
    });

    openEditTarget.click(openEdit);


    function closeEditArea() {
        id=0;
        Ptarget.fadeOut();
    }

    $(".closeEditArea").click(closeEditArea);



    EditButtonTarger.click(uploadArticle)
}();






//注册登录模块---------------------------------------------------------------
!function(){
    var id=0;
    var PTarget=$(".register");
    var nameTarget=$(".register input[name=name]");
    var passWordTarget=$(".register input[name=passWord]");
    var SpassWordTarget=$(".register input[name=SPassWord]");
    var CheckCodeTarget=$(".register input[name=CheckCode]");
    var successTarget=$(".register .SuccessMsg");
    var msgs=$(".loginContent .loginMsg");
    var loginTitleTarget=$(".loginTitle");
    var RLLinkTarget=$("#RLLink");
    getCode();
    //界面操作
    function reset() {
        for(var i=0;i<msgs.length;++i){
            hideMsg(i);
        }
        normal(nameTarget);
        normal(passWordTarget);
        normal(SpassWordTarget);
        normal(CheckCodeTarget);
        successTarget.fadeOut(1);
    }
    $(".closeRegister").click(function(){
            PTarget.fadeOut();
    });
    $(".loginButton").click(function(){
        reset();
        $(".register").fadeIn();
    });

    $(".logoutButton").click(logout);

    function LTR() {
        reset();
        SpassWordTarget.css("display","block");
        CheckCodeTarget.css("display","block");
        $("#CheckCode").css("display","block");
        $(".RLButton").text("注册")
        RLLinkTarget.text("登录");
        $(".register").css("height",410);
        loginTitleTarget.text("注册")
    }
    function RTL() {
        reset();
        SpassWordTarget.css("display","none");
        CheckCodeTarget.css("display","none");
        $("#CheckCode").css("display","none");
        $(".RLButton").text("登录")
        RLLinkTarget.text("注册");
        $(".register").css("height",300);
        loginTitleTarget.text("登录")
    }

    function RTL_LTR() {
        var title=loginTitleTarget.text();
        if (title=="注册"){
            RTL();
        }else if(title=="登录"){
            LTR();
        }
    }

    RLLinkTarget.click(RTL_LTR);
    successTarget.click(function () {
        $(this).fadeOut();
    });

    function sMsg(msg) {
        sucessMsg(msg,"green","rgba(100,200,100,0.7)");
    }
    function fMsg(msg) {
        sucessMsg(msg,"red","rgba(200,100,100,0.7)");
    }
    function sucessMsg(msg,color1,color2) {
        successTarget.html("<p>"+msg+"</p>");
        successTarget.fadeIn(150);
        successTarget.css({color:color1,"background-color":color2});
    }

    function closeMag() {
        successTarget.fadeOut(1)
    }

    //功能操作
    function login(){
        var title=$(".loginTitle").text();
        var name=nameTarget.val();
        var passWord=passWordTarget.val();
        var SpassWord=SpassWordTarget.val();
        var CC=CheckCodeTarget.val();
        if (title=="注册"){
            if(checkPassWord()){
                checkCode(function () {
                    checkName(function () {
                        $.post("/register",{name:name,passWord:passWord,code:CC,cid:id},function (o) {
                            if (o){
                                sMsg("注册成功")
                                setTimeout(function () {
                                    reset()
                                    RTL();
                                },500);
                            }else {
                                fMsg("注册失败")
                            }
                        })
                    })
                })
            }

        }else if(title=="登录"){
            if(checkName()&&checkPassWord()){
                $.post("/login",{name:name,passWord:passWord},function (o) {
                    if(o=="true"){
                        sMsg("登录成功");
                        setTimeout(function () {
                            location.reload(true);
                        },1500);
                    }else {
                        fMsg(o)
                    }
                })
            }
        }
    }
    $(".RLButton").click(login);
    passWordTarget.keydown(function(event){
        if(event.keyCode==13){
            login();
        }
    });
    function logout() {
        $.post("/logout",function () {
            location.href="/";
        });
    }

    var X=28;
    var Y=47;
    function checkName(func) {
        var x=X;
        var y=Y;
        var name=nameTarget.val();
        var title=$(".loginTitle").text();
        if(name==null||name.length<6){
            no(nameTarget);
            showMsg(0,x,y,"账号长度必须大于5");
            return false;
        }else if(name.search(/[a-zA-Z]/i)>0||name.search(/[0-9]/)==-1){
            no(nameTarget);
            showMsg(0,x,y,"账号必须字母开头并包含数字");
            return false;
        }
        if (title=="注册"){
            $.post("/CheckName",{name:name},function (o) {
                if (o){
                    yes(nameTarget);
                    if(typeof eval(func)=="function")
                    func();
                }else {
                    showMsg(0,x,y,"账号不合法或者已经被使用！");
                    no(nameTarget);
                }
            })
        }
        return true;
    }
    function checkPassWord() {
        var x=X;
        var y=Y+56;
        var title=$(".loginTitle").text();
        var passWord=passWordTarget.val();
        if(passWord==null||passWord.length<8){
            no(passWordTarget);
            showMsg(1,x,y,"密码必须大于8位");
            return false;
        }else if(passWord.search(/[a-zA-Z]/i)==-1||passWord.search(/[0-9]/)==-1){
            no(passWordTarget);
            showMsg(1,x,y,"密码必须包含字母和数字");
            return false;
        }
        if(title=="登录") return true;

        yes(passWordTarget);
        if(checkSpassWord()){
            return true;
        }
        return false;
    }
    function checkSpassWord() {
        var x=X;
        var y=Y+112;
        var passWord=passWordTarget.val();
        var SpassWord=SpassWordTarget.val();
        if(passWord==null||passWord==""){
            return false;
        }
        if (passWord!=SpassWord){
            no(SpassWordTarget);
            showMsg(2,x,y,"密码不一致！");
            return false;
        }
        yes(SpassWordTarget);
        return true;
    }
    var checkCode=function (func) {
        var x=X;
        var y=Y+168;
        var CC=$("input[name=CheckCode]").val();
        $.post("/codeCheck",{id:id,code:CC},function(o){
            if(o){
                yes(CheckCodeTarget);
                if(typeof eval(func)=="function")
                func();
            }else {
                getCode();
                showMsg(3,x,y,"验证码错误！");
                no(CheckCodeTarget);
                // if(func.isFunction())
                // func("false");
            }
        });
    };


    nameTarget.blur(checkName);
    passWordTarget.blur(checkPassWord);
    SpassWordTarget.blur(checkSpassWord);
    CheckCodeTarget.blur(checkCode);


    function yes(o) {
        $(o).css("background-color","rgba(0,255,0,0.5)")
    }
    function normal(o) {
        $(o).css("background-color","rgba(255,255,255,0.7)")
        $(o).val("");
    }
    function no(o) {
        $(o).css("background-color","rgba(255,0,0,0.5)")
    }
    function showMsg(i, left, top, msg) {
        $(msgs[i]).css({display:"inline-block",left:left,top:top});
        $(msgs[i]).text(msg);
    }
    function hideMsg(i) {
        $(msgs[i]).css("display","none");
    }

    nameTarget.focus(function () {
        hideMsg(0);
        normal(this);
    });
    passWordTarget.focus(function () {
        hideMsg(1);
        normal(this);
    });
    SpassWordTarget.focus(function () {
        hideMsg(2);
        normal(this);
    });
    CheckCodeTarget.focus(function () {
        hideMsg(3);
        normal(this);
    });

    $("#CheckCode").click(getCode);
    function getCode(){
        id=Math.floor(Math.random()*1000);
        document.getElementById("CheckCode").src="/CheckCode?id="+id;
    }
}();



//好友模块-------------------------------------------------------------------------
!function(){
    var rdm=Math.random();
    var csDiv=$(".logo div");
    function backGroundRed() {
        this.style.background="radial-gradient(red,white)";
    }
    //获取自己的信息
    function getMineInfo(){
        $.post("/getMineInfo",function(myInfo){
            if(myInfo){
                var js=JSON.parse(myInfo);
                $(".friendsBar .MyPhoto").attr("src",js.photo+"?"+rdm);
                $(".friendsBar .title").text(js.nickName);
            }
        })
    }
    getMineInfo();

    var f=$(".friendsBar");
    var talkContentTarget=$(".talkContent");
    var sendMsgTarget=$(".sendMsg");
    var sendButtonTarget=$(".sendButton");
    var friendTarget=$(".friend");
    //自己的id
    var selfId=0;
    var selfImg="";
    //正在聊天的好友的id
    var id;
    var friendImg;
    //聊天记录
    function Data() {};
    Data.prototype={
        get:function () {
            var data=sessionStorage["user"+selfId];
            if (data==null||data==""){
                data="{}";
            }
            return JSON.parse(data);
        },
        save:function (data) {
            sessionStorage["user"+selfId]=JSON.stringify(data);
        },
        addFriend:function (i) {
            var data=this.get();
            data[i]=[];
            this.save(data);
        },
        addMsg:function (i, msg) {
            var data=this.get();
            var temp=data[i];
            temp.push(msg);
            if(temp.length>100){
                temp.shift();
            }
            data[i]=temp;
            this.save(data);
        }
    };


    var friends;

    var socket;
    var msgCode=0;

    function msgModel(content){
        this.id=msgCode;
        this.toid=id;
        this.content=content;
        this.time=new Date().getTime();
    }
    function getMsgCode() {
        $.post("/getMsgCode",function (o) {
            msgCode=o;
            var url=location.host;
            socket=new WebSocket("ws://"+url+"/socket");
            socket.onopen=function(){
                var js=new msgModel(0,"");
                var msg=JSON.stringify(js);
                socket.send(msg);
            };
            socket.onmessage=function(msg){
                var js=JSON.parse(msg.data);
                //console.log(js);
                if(js.toid==0&&js.id==0){
                    backGroundRed.call(csDiv[4]);
                }else if (js.toid==0){
                    selfId=js.id;
                    friends=new Data();
                    getMyFriends();
                }else if(typeof friends.get()[js.id]!="undefined"){
                    friends.addMsg(js.id,js);
                }else if (typeof friends.get()[js.toid] != 'undefined'){
                    friends.addMsg(js.toid,js);
                }
                if(js.id!=0&&js.toid!=0){
                    if(js.id==id||js.toid==id){
                        showMsg(js);
                    }else {
                        $("#"+js.id+" img").addClass("InOutCls");
                        backGroundRed.call(csDiv[3]);
                    }
                }
            }
        })
    }

    //todo: 获取好友列表
    function getMyFriends(){
        $.post("/getFriends",function(o){
            if(o!=null){
                var js=JSON.parse(o);
                if(typeof js == "object"){
                    showFriends(js);
                }
            }
        })
    }


    function setFriendModel(js){
        //console.log(js);
        var friend= friends.get();
        if (typeof friend[js.id] == 'undefined'){
            friends.addFriend(js.id);
        }
        var temp=friendTarget.clone(true);
        temp.dblclick(showTalkPanel);
        temp.css("display","block");
        temp.attr("id",js.id);
        temp.find("img").attr("src",js.photo+"?"+rdm);
        var a=temp.find("a.nameList");
        a.attr("href","user"+js.id);
        a.text(js.nickName?js.nickName:js.name);
        f.append(temp);
    }

    function showFriends(js){
        $(".friend").remove();
        for(var i in js){
            setFriendModel(js[i]);
        }
    }

    //弹出 好友侧边栏
    function opside() {
        var l= f.css("left");
        if(l=="0px"){
            $(".friendsBar").animate({left: -f.width()})
        }else{
            $(".friendsBar").animate({left:0})
        }
        if (msgCode==0){
            getMsgCode();
        }
        selfImg=$(".friendsBar .MyPhoto").attr("src");
        //getMyFriends();
    }
    //弹出 聊天框
    function showTalkPanel() {
        id=this.id;
        var img=$("#"+id+" img");
        img.removeClass("InOutCls");
        friendImg=img.attr("src");
        $(".talkPanel").css({left:"30%",top:"30%",display:"inline-block"});
        $(".friendName").text($(this).text())
        talkContentTarget.children().remove();
        showMsgs(id);
    }

//发送消息
    function sendMsg(msg){
        var js=new msgModel(msg);
        //console.log(js);
        socket.send(JSON.stringify(js));
    }
    function toSend(){
        var content=sendMsgTarget.val();
        //console.log(content);
        sendMsgTarget.val("");
        sendMsg(content);
    }
    //显示消息
    function showMsgs(id){
        var arr=friends.get()[id];
        if(typeof arr == "undefined"){
            friends.addFriend(id);
            arr=[];
        }
        for(var i = 0;i<arr.length;++i){
            showMsg(arr[i]);
        }
    }
    function showMsg(js){
        var msgDom=$("<div>");
        var imgDom=$("<img>");
        var timeDom=$("<div>");
        var contentDom=$("<div>");
        timeDom.text(new Date(parseInt(js.time)).toLocaleString());
        timeDom.css({"font-size":"0.5em",color:"#999",margin:"0 15px"});
        contentDom.text(js.content);
        contentDom.css({margin:"0 15px"});
        imgDom.css({width:"30px",height:"30px","border-radius": "50%"});
        if(js.id==id){
            imgDom.attr("src",friendImg);
        }else{
            imgDom.attr("src",selfImg);
            msgDom.css("text-align","right");
        }
        msgDom.append(timeDom);
        msgDom.append(imgDom);
        msgDom.append(contentDom);
        talkContentTarget.append(msgDom);
        talkContentTarget[0].scrollTop=talkContentTarget[0].scrollHeight;
    }

    sendButtonTarget.click(toSend);
    sendMsgTarget.keypress(function (event) {
        if(event.keyCode==13){
            toSend();
        }
    })
    friendTarget.dblclick(showTalkPanel);
    $("#myFriends").click(opside);



    //$(".nameList").click(function () {
    //    open("./user.html?id="+this.parentNode.id);
    //});

    $(".closeTalkPanel").click(function(){
        $(".talkPanel").css("display","none");
    });




}();

